from bs4 import BeautifulSoup

soup = BeautifulSoup("""<div>
    <p>test 1</p><b>test 2</b><h>test 3</h></div>
""", 'html.parser')

print(soup.b.next_sibling)     # 返回后面的兄弟节点 

print(soup.b.previous_sibling)   # 返回前面的兄弟节点

print(soup.h.next_sibling)      # 没有就返回None